<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <title>官方资讯</title>
    <link
      href="https://cdn.quilljs.com/1.3.6/quill.snow.css"
      rel="stylesheet"
    />
    <script
      type="text/javascript"
      src="http://cdn.webfont.youziku.com/wwwroot/js/wf/youziku.api.min.js"
    ></script>
    <script type="text/javascript">
      $youziku.load('body', 'd3fef98ddac14e71aee3f8fc2caa0bcd', 'PingFangSC_R')
      /*$youziku.load("#id1,.class1,h1", "d3fef98ddac14e71aee3f8fc2caa0bcd", "PingFangSC_R");*/
      $youziku.draw()
    </script>
    <style>
      .tag {
        display: inline-block;
        padding: 3px 4px;
        color: #fff;
        background-color: #83dab0;
      }
      p img {
        width: 100%;
      }
      .title {
        font-size: 18px;
        line-height: 25px;
        color: #131313;
        font-weight: 600;
      }
      .state {
        margin-top: 10px;
      }
      .date {
        font-size: 12px;
        line-height: 25px;
        color: #6a6969;
      }
      .page_bd {
        white-space: normal;
      }
    </style>
  </head>
  <body>
    <!-- Create the editor container -->
    <div id="editor"></div>
    <div class="page">
      <div class="header"><div class="tag">最新资讯</div></div>
      <div class="ql-editor page_bd news-body">
        <div class="title"></div>
        <div class="state">
          <time class="date"></time>
        </div>
        <div class="news-body">
          <!-- js -->
        </div>
      </div>
    </div>
    <script src="https://cdn.bootcss.com/jquery/1.12.4/jquery.min.js"></script>
    <!-- Include the Quill library -->
    <!-- <script src="https://cdn.quilljs.com/1.3.6/quill.js"></script> -->

    <!-- Initialize Quill editor -->
    <script>
      // var quill = new Quill('#editor', {
      //   theme: 'snow'
      // })

      $(function() {
        var matchId = window.location.href.match(/id=(\d+)/)
        var newsId = matchId[1] ? matchId[1] : 0

        var apiList = {
          newsDetail: 'http://www.hepulan.com/api2/news'
        }

        var $newsBody = $('.news-body')
        var $newsTitle = $('.title')
        var $newsDate = $('.date')

        $.ajax({
          type: 'get',
          url: apiList.newsDetail + '/' + newsId,
          data: {},
          dataType: 'json',
          success: function(resp) {
            if (resp.code === 200 && resp.data.length !== 0) {
              console.log(resp)
              $newsTitle.append(resp.data.title)
              $newsDate.append(resp.data.post_date)
              $newsBody.append(resp.data.content)
            }
          }
        })
      })
    </script>
  </body>
</html>
